package com.example.common;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.io.Serializable;
@Data
public class Result implements Serializable {

    private int code; // 状态码
    private String msg; // 返回消息
    private Object data;
    public static Result success (String msg ,Object data) {
        Result result = new Result();
        result.code = 200;
        result.msg = msg;
        result.data = data;
        return result;
    }

    public static Result success (Object data) {
        Result result = new Result();
        result.code = 200;
        result.data = data;
        return result;
    }


    public static Result success (String msg) {
        Result result = new Result();
        result.code = 200;
        result.msg = msg;
        return result;
    }

    public static Result fail(int code , String msg) {
        Result result = new Result();
        result.code = code;
        result.msg = msg;
        return result;
    }
}
